<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input id="d1" value="2012-8-9"  />
		<script>
			var s=d1.value;
			var firstIndex=s.indexOf("-");
			var secondIndex=s.indexOf("-",firstIndex+1);
			var y=s.substring(0,firstIndex);
			var m=s.substring(firstIndex+1,secondIndex);
			var d=s.substring(secondIndex+1);
			alert("年:"+y);
			alert("月:"+m);
			alert("日:"+d);
		</script>
	</body>
</html>
